// 用户登录验证在TS装饰器中的实现
const userZrf = {
  name: 'zrf',
  isLogin: false,
}

const AccessDecorator: MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
  const method = descriptor.value

  descriptor.value = () => {
    if (userZrf.isLogin === true) {
      return method()
    }
    console.log('请登录后操作');
    // location.href = 'login.html'
    console.log('3s后跳转到登录页面');

  }

}
{
  class Article {
    show() {
      console.log('显示文章');
    }
    @AccessDecorator
    store() {
      console.log('保存文章');
    }
  }

  new Article().show()
  new Article().store()

}